Telegram Group & Telegram Channel
📌 Разбор Python-задачи

Если вы ответил 2 — это ловушка

def func(a, b):
res = a + b

res = func(1, 1)
print(res)


На первый взгляд кажется, что res = 2. Но нет.

➡️ Что происходит

1. Функция func(a, b) складывает a + b и сохраняет в переменную res внутри функции.

2. Но! Функция ничего не возвращает. В Python по умолчанию любая функция без return возвращает None.

3. Следовательно, res = func(1, 1) присваивает None.

4. На экран выводится None.

📎 Пост с задачей

Proglib Academy #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/proglib_academy/2779
Create:
Last Update:

📌 Разбор Python-задачи

Если вы ответил 2 — это ловушка

def func(a, b):
res = a + b

res = func(1, 1)
print(res)


На первый взгляд кажется, что res = 2. Но нет.

➡️ Что происходит

1. Функция func(a, b) складывает a + b и сохраняет в переменную res внутри функции.

2. Но! Функция ничего не возвращает. В Python по умолчанию любая функция без return возвращает None.

3. Следовательно, res = func(1, 1) присваивает None.

4. На экран выводится None.

📎 Пост с задачей

Proglib Academy #буст

BY Proglib.academy | IT-курсы


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/proglib_academy/2779

View MORE
Open in Telegram


Proglib academy | IT курсы Telegram | DID YOU KNOW?

Date: |

The Singapore stock market has alternated between positive and negative finishes through the last five trading days since the end of the two-day winning streak in which it had added more than a dozen points or 0.4 percent. The Straits Times Index now sits just above the 3,060-point plateau and it's likely to see a narrow trading range on Monday.

Telegram has exploded as a hub for cybercriminals looking to buy, sell and share stolen data and hacking tools, new research shows, as the messaging app emerges as an alternative to the dark web.An investigation by cyber intelligence group Cyberint, together with the Financial Times, found a ballooning network of hackers sharing data leaks on the popular messaging platform, sometimes in channels with tens of thousands of subscribers, lured by its ease of use and light-touch moderation.Proglib academy | IT курсы from ms


Telegram Proglib.academy | IT-курсы
FROM USA